<script setup>
import SvgIcon from '@/components/SvgIcon.vue'
import { getWXLoginData } from '@/api/sys'
import brodacast from './brodacast'

const onWXclick = async () => {
  const { appId, appSecret, redirectUri, scope, state } = await getWXLoginData()
  window.open(
    `https://open.weixin.qq.com/connect/qrconnect?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`,
    '',
    'height=525,width=585, toolbar=no, menubar=no, scrollbars=no, status=no, location=yes, resizable=yes'
  )
  // 下面会跳转线上地址，但是没法本地调测故该功能无法开发
  brodacast.wait().then(async ({ code }) => {
    console.log('微信扫码登录成功')
    console.log(code)
  })
}
</script>
<template>
  <SvgIcon name="wexin" class="w-10 h-10" @click="onWXclick" />
</template>

<style lang="scss" scoped></style>
